package com.gms.service.placemanager.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gms.entity.place.Place;
import com.gms.entity.place.PlaceFeeStander;
import com.gms.mapper.placemanager.PlaceFeeStanderMapper;
import com.gms.service.placemanager.PlaceFeeStanderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class PlaceFeeStanderServiceImpl extends ServiceImpl<PlaceFeeStanderMapper, PlaceFeeStander> implements PlaceFeeStanderService {

    @Autowired
    private PlaceFeeStanderMapper placeFeeStanderMapper;

    @Override
    public List<PlaceFeeStander> QueryPlaceFeeStander(String type) {
        QueryWrapper<PlaceFeeStander> queryWrapper = new QueryWrapper<>();
        Map<String,Object> map = new HashMap<>();
        map.put("place_type",type);
        map.put("stander_state","正常");
        queryWrapper.allEq(map,false);
        return placeFeeStanderMapper.selectList(queryWrapper);
    }

    @Override
    public void InsertPlaceStander(PlaceFeeStander placeFeeStander) {
        placeFeeStanderMapper.insert(placeFeeStander);
    }

    @Override
    public void UpdatePlaceStander(Integer feeid) {
        UpdateWrapper<PlaceFeeStander> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set("stander_state","已删除");
        updateWrapper.eq("feestander_id",feeid);
        placeFeeStanderMapper.update(null,updateWrapper);
    }

    @Override
    public boolean SelectPlaceFeeStander(String placefee) {
        QueryWrapper<PlaceFeeStander> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("place_type", placefee);
        queryWrapper.eq("stander_state", "正常");
        Integer integer = placeFeeStanderMapper.selectCount(queryWrapper);
        return integer != 0;
    }

    @Override
    public void UpdatePlaceFeeStander1(PlaceFeeStander placeFeeStander) {
        placeFeeStanderMapper.updateById(placeFeeStander);
    }
}
